<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>出库申请查询</title>

    <link rel="stylesheet" href="../css/productionPlanRegistrationCss.css">


    <link rel="stylesheet" href="../static/css/style.css">

    <script src="../js/jquery-2.1.1.min.js"></script>
    <!-- 新 Bootstrap4 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/bootstrap-table.min.css">
    <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>

    <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
    <script src="../static/js/global.min.js"></script>
    <script src="../js/bootstrap-table.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/bootstrap-table/1.21.0/locale/bootstrap-table-zh-CN.js"></script>
    <script>
        //渲染表格
        $(function () {
            //用户信息
            $.ajax({
                type:'POST',
                url: '/userShow.action',
                success:function (user){
                    $('#checker').val(user.loginId);
                }
            });
            $('#table').bootstrapTable({
                //请求方式  get请求中文会乱码，建议使用post请求
                method: 'post',
                //请求头部的设置
                contentType: 'application/json',
                //路径
                url: '/hj/queryWarehouse.action',
                //设置交替行样式
                striped: true,
                //初始显示页号
                pageNumber: 1,
                //设置表格高度
                height: 600,
                //是否显示分页
                pagination: true,
                //设置是服务端分页还是客户端分页
                sidePagination: 'server',
                //页大小
                pageSize:5,
                //分页列表
                pageList:[5,10],
                //上传到服务端的参数
                queryParams: function (params) {
                    return {
                        // 计算页号(当前页)
                        pageNum: (params.offset / params.limit) + 1,
                        // 计算页大小
                        pageSize: params.limit,

                    };
                },
                // 定义列名
                columns: [
                    {title: '申请单编号', field: 'payId', align: 'center',
                        formatter: function (value,row,index) {
                            return "<a href='#' data-toggle=\"modal\" data-target=\"#myModal\" onclick='make("+JSON.stringify(row)+")'>"+value+"</a>";
                        },},
                    {title: '出库理由', field: 'reason', align: 'center'},
                    {title: '登记人', field: 'register', align: 'center'},
                    {title: '登记时间', field: 'registerTime', align: 'center'},
                    {title: '总件数', field: 'amountSum', align: 'center'},
                    {title: '总金额（元）', field: 'costPriceSum', align: 'center'},
                    {title: '审核状态', field: 'checkTag', align: 'center',
                        formatter: function (value,row,index) {
                            if(value==="S001-0"){
                                return "<span class=\"badge badge-warning\"><font>等待审核</font><span class=\"ms-1 fas fa-stream\"></span></span>";
                            }else if(value==="S001-1"){
                                return "<span class=\"badge badge-success\"><font >审核通过</font><span class=\"ms-1 fa fa-check\"></span></span>";
                            }else{
                                return "<span class=\"badge badge-danger\"><font >审核不通过</font><span class=\"ms-1 fa fa-redo\"></span></span>";
                            }
                        },
                    }
                ]
            });
        })

        //审核
        function make(obj){
            $.ajax({
                type:'POST',
                url: '/hj/queryWarehouseDetail.action',
                data:'id='+obj.id,
                success:function (resultSPayDetails){
                    $('#tbodyModal').html("");
                    $('#payId').val(obj.payId);
                    $('#storer').val(obj.storer);
                    $('#reason').val(obj.reason);
                    $('#amountSum').val(obj.amountSum);
                    $('#costPriceSum').val(obj.costPriceSum);
                    $('#register').val(obj.register);
                    $('#registerTime').val(obj.registerTime);
                    $('#remark').val(obj.remark);
                    $('#reasonexact').val(obj.reasonexact);
                    alert(obj.checkTime)
                    $('#checkTime').val(obj.checkTime);
                    $.each(resultSPayDetails,function (index,SPayDetail){
                        $('#tbodyModal').append("<tr>" +
                            "<td>"+SPayDetail.id+"</td>" +
                            "<td>"+SPayDetail.product_id+"</td>" +
                            "<td>"+SPayDetail.product_name+"</td>" +
                            "<td>"+SPayDetail.number+"</td>" +
                            "<td>"+SPayDetail.amount+"</td>" +
                            "<td>"+SPayDetail.amount_unit+"</td>" +
                            "<td>"+SPayDetail.cost_price+"</td>" +
                            "<td>"+SPayDetail.subtotal+"</td>" +
                            "</tr>")
                    })
                }
            });

        }

    </script>
</head>
<body>

<table id="table"></table>

<div class="modal fade" id="myModal">
    <div class="modal-dialog modal-xl">
        <div class="modal-content">


            <!-- 模态框主体 -->
            <div class="modal-body">
                <div class="d1">
                    <div style="margin-top: 10px"><h2>出库申请单</h2>

                    </div>
                    <div class="container-fluid row" style="margin-top: 10px">
                        <div class="input-group mb-4 col">
                            <div class="input-group-prepend">
                                <span class="input-group-text">申请单编号<span class="text-danger scale5 ms-2">*</span></span>
                            </div>
                            <input type="text" class="form-control" id="payId" style="background-color: white" readonly>
                        </div>
                        <div class="input-group mb-4 col">
                            <div class="input-group-prepend">
                                <span class="input-group-text">出库人<span class="text-danger scale5 ms-2">*</span></span>
                            </div>
                            <input type="text" class="form-control" id="storer" style="background-color: white" readonly>
                        </div>
                        <div class="input-group mb-4 col">
                            <div class="input-group-prepend">
                                <span class="input-group-text">出库理由<span class="text-danger scale5 ms-2">*</span></span>
                            </div>
                            <input type="text" class="form-control" id="reason" style="background-color: white" readonly>
                        </div>
                    </div>

                    <div class="container-fluid row">
                        <table class="table table-bordered" style="text-align: center">
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>产品编号</th>
                                <th>产品名称</th>
                                <th>当前库存数量</th>
                                <th>数量</th>
                                <th>单位</th>
                                <th>成本单价（￥）</th>
                                <th>小计(￥)</th>
                            </tr>
                            </thead>
                            <tbody id="tbodyModal">


                            </tbody>
                        </table>
                    </div>

                    <div class="container-fluid row">
                        <div class="input-group mb-4 col">
                            <div class="input-group-prepend">
                                <span class="input-group-text">总件数<span class="text-danger scale5 ms-2">*</span></span>
                            </div>
                            <input type="text" class="form-control" id="amountSum" style="background-color: white" readonly>
                        </div>
                        <div class="input-group mb-4 col">
                            <div class="input-group-prepend">
                                <span class="input-group-text">总金额<span class="text-danger scale5 ms-2">*</span></span>
                            </div>
                            <input type="text" class="form-control" id="costPriceSum" style="background-color: white" readonly>
                        </div>
                    </div>

                    <div class="container-fluid row">
                        <div class="input-group mb-4 col">
                            <div class="input-group-prepend">
                                <span class="input-group-text">登记人<span class="text-danger scale5 ms-2">*</span></span>
                            </div>
                            <input type="text" class="form-control" id="register" style="background-color: white" readonly>
                        </div>
                        <div class="input-group mb-4 col">
                            <div class="input-group-prepend">
                                <span class="input-group-text">登记时间<span class="text-danger scale5 ms-2">*</span></span>
                            </div>
                            <input type="text" class="form-control" id="registerTime" style="background-color: white" readonly>
                        </div>
                    </div>

                    <div class="container-fluid row">
                        <div class="input-group mb-4 col">
                            <div class="input-group-prepend">
                                <span class="input-group-text">审核人<span class="text-danger scale5 ms-2">*</span></span>
                            </div>
                            <input type="text" class="form-control" id="checker" style="background-color: white" readonly>
                        </div>
                        <div class="input-group mb-4 col">
                            <div class="input-group-prepend">
                                <span class="input-group-text">审核时间<span class="text-danger scale5 ms-2">*</span></span>
                            </div>
                            <input type="text" class="form-control" id="checkTime" style="background-color: white" readonly>
                        </div>
                    </div>


                    <div class="col" style="margin-bottom: 10px">
                        <span><h6>备注:</h6></span>
                        <textarea class="form-control" rows="4" id="remark"
                                  style="height: 115px;border-color: #c7c7c7;resize:none"></textarea>
                    </div>
                    <div class="col" style="margin-bottom: 10px">
                        <span><h6>出库详细理由:</h6></span>
                        <textarea class="form-control" rows="4" id="reasonexact"
                                  style="height: 115px;border-color: #c7c7c7;resize:none"></textarea>
                    </div>
                </div>

            </div>

            <!-- 模态框底部 -->
            <div class="modal-footer">
                <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
            </div>

        </div>
    </div>
</div>
<script src="../js/jquery.dataTables.min.js"></script>
</body>
</html>